<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>lwIP: IEEE 802.1D bridge</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">lwIP
   &#160;<span id="projectnumber">2.1.2</span>
   </div>
   <div id="projectbrief">Lightweight IP stack</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__bridgeif.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#groups">Modules</a> &#124;
<a href="#nested-classes">Data Structures</a> &#124;
<a href="#define-members">Macros</a> &#124;
<a href="#typedef-members">Typedefs</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">IEEE 802.1D bridge<div class="ingroups"><a class="el" href="group__netifs.html">NETIFs</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="groups"></a>
Modules</h2></td></tr>
<tr class="memitem:group__bridgeif__opts"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bridgeif__opts.html">Options</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:group__bridgeif__fdb"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bridgeif__fdb.html">FDB example code</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Data Structures</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structbridgeif__initdata__s.html">bridgeif_initdata_s</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:ga3d41c7905b61aef3a3b8c61b3af7879f"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bridgeif.html#ga3d41c7905b61aef3a3b8c61b3af7879f">BRIDGEIF_INITDATA1</a>(max_ports,  max_fdb_dynamic_entries,  max_fdb_static_entries,  ethaddr)&#160;&#160;&#160;{ethaddr, max_ports, max_fdb_dynamic_entries, max_fdb_static_entries}</td></tr>
<tr class="separator:ga3d41c7905b61aef3a3b8c61b3af7879f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaaaeb47fbf1dd6c30cb502343fa0d0741"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bridgeif.html#gaaaeb47fbf1dd6c30cb502343fa0d0741">BRIDGEIF_INITDATA2</a>(max_ports,  max_fdb_dynamic_entries,  max_fdb_static_entries,  e0,  e1,  e2,  e3,  e4,  e5)&#160;&#160;&#160;{{e0, e1, e2, e3, e4, e5}, max_ports, max_fdb_dynamic_entries, max_fdb_static_entries}</td></tr>
<tr class="separator:gaaaeb47fbf1dd6c30cb502343fa0d0741"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a>
Typedefs</h2></td></tr>
<tr class="memitem:gac47f8ce66bc6dad5dd9829467f93a1bb"><td class="memItemLeft" align="right" valign="top">typedef struct <a class="el" href="structbridgeif__initdata__s.html">bridgeif_initdata_s</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bridgeif.html#gac47f8ce66bc6dad5dd9829467f93a1bb">bridgeif_initdata_t</a></td></tr>
<tr class="separator:gac47f8ce66bc6dad5dd9829467f93a1bb"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gad20fea2657431d4a0905be80cb0b4666"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bridgeif.html#gad20fea2657431d4a0905be80cb0b4666">bridgeif_fdb_add</a> (struct <a class="el" href="structnetif.html">netif</a> *bridgeif, const struct <a class="el" href="structeth__addr.html">eth_addr</a> *addr, bridgeif_portmask_t ports)</td></tr>
<tr class="separator:gad20fea2657431d4a0905be80cb0b4666"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga79349b1e9d0f944e8abad5a6cfb1c8e8"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bridgeif.html#ga79349b1e9d0f944e8abad5a6cfb1c8e8">bridgeif_fdb_remove</a> (struct <a class="el" href="structnetif.html">netif</a> *bridgeif, const struct <a class="el" href="structeth__addr.html">eth_addr</a> *addr)</td></tr>
<tr class="separator:ga79349b1e9d0f944e8abad5a6cfb1c8e8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga23cc2c5f8fccefc470093840cc53727c"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bridgeif.html#ga23cc2c5f8fccefc470093840cc53727c">bridgeif_init</a> (struct <a class="el" href="structnetif.html">netif</a> *<a class="el" href="structnetif.html">netif</a>)</td></tr>
<tr class="separator:ga23cc2c5f8fccefc470093840cc53727c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga51b7d1af22f7023aabd8502aadf77c77"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__bridgeif.html#ga51b7d1af22f7023aabd8502aadf77c77">bridgeif_add_port</a> (struct <a class="el" href="structnetif.html">netif</a> *bridgeif, struct <a class="el" href="structnetif.html">netif</a> *portif)</td></tr>
<tr class="separator:ga51b7d1af22f7023aabd8502aadf77c77"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>This file implements an IEEE 802.1D bridge by using a multilayer netif approach (one hardware-independent netif for the bridge that uses hardware netifs for its ports). On transmit, the bridge selects the outgoing port(s). On receive, the port netif calls into the bridge (via its netif-&gt;input function) and the bridge selects the port(s) (and/or its netif-&gt;input function) to pass the received pbuf to.</p>
<p>Usage:</p><ul>
<li>add the port netifs just like you would when using them as dedicated netif without a bridge<ul>
<li>only NETIF_FLAG_ETHARP/NETIF_FLAG_ETHERNET netifs are supported as bridge ports</li>
<li>add the bridge port netifs without IPv4 addresses (i.e. pass 'NULL, NULL, NULL')</li>
<li>don't add IPv6 addresses to the port netifs!</li>
</ul>
</li>
<li>set up the bridge configuration in a global variable of type 'bridgeif_initdata_t' that contains<ul>
<li>the MAC address of the bridge</li>
<li>some configuration options controlling the memory consumption (maximum number of ports and FDB entries)</li>
<li>e.g. for a bridge MAC address 00-01-02-03-04-05, 2 bridge ports, 1024 FDB entries + 16 static MAC entries: bridgeif_initdata_t mybridge_initdata = <a class="el" href="group__bridgeif.html#ga3d41c7905b61aef3a3b8c61b3af7879f">BRIDGEIF_INITDATA1(2, 1024, 16, ETH_ADDR(0, 1, 2, 3, 4, 5))</a>;</li>
</ul>
</li>
<li>add the bridge netif (with IPv4 config): struct netif bridge_netif; netif_add(&amp;bridge_netif, &amp;my_ip, &amp;my_netmask, &amp;my_gw, &amp;mybridge_initdata, bridgeif_init, tcpip_input); NOTE: the passed 'input' function depends on BRIDGEIF_PORT_NETIFS_OUTPUT_DIRECT setting, which controls where the forwarding is done (netif low level input context vs. tcpip_thread)</li>
<li>set up all ports netifs and the bridge netif</li>
<li>When adding a port netif, NETIF_FLAG_ETHARP flag will be removed from a port to prevent ETHARP working on that port netif (we only want one IP per bridge not per port).</li>
<li>When adding a port netif, its input function is changed to call into the bridge.</li>
</ul>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a id="ga3d41c7905b61aef3a3b8c61b3af7879f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga3d41c7905b61aef3a3b8c61b3af7879f">&#9670;&nbsp;</a></span>BRIDGEIF_INITDATA1</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define BRIDGEIF_INITDATA1</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">max_ports, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">max_fdb_dynamic_entries, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">max_fdb_static_entries, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">ethaddr&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td>&#160;&#160;&#160;{ethaddr, max_ports, max_fdb_dynamic_entries, max_fdb_static_entries}</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Use this for constant initialization of a bridgeif_initdat_t (ethaddr must be passed as <a class="el" href="lwip_2prot_2ethernet_8h.html#a19c72ce98569e0fb55948a7587d704ee">ETH_ADDR()</a>) </p>

</div>
</div>
<a id="gaaaeb47fbf1dd6c30cb502343fa0d0741"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaaaeb47fbf1dd6c30cb502343fa0d0741">&#9670;&nbsp;</a></span>BRIDGEIF_INITDATA2</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define BRIDGEIF_INITDATA2</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">max_ports, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">max_fdb_dynamic_entries, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">max_fdb_static_entries, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">e0, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">e1, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">e2, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">e3, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">e4, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">e5&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td>&#160;&#160;&#160;{{e0, e1, e2, e3, e4, e5}, max_ports, max_fdb_dynamic_entries, max_fdb_static_entries}</td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Use this for constant initialization of a bridgeif_initdat_t (each byte of ethaddr must be passed) </p>

</div>
</div>
<h2 class="groupheader">Typedef Documentation</h2>
<a id="gac47f8ce66bc6dad5dd9829467f93a1bb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gac47f8ce66bc6dad5dd9829467f93a1bb">&#9670;&nbsp;</a></span>bridgeif_initdata_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">typedef struct <a class="el" href="structbridgeif__initdata__s.html">bridgeif_initdata_s</a>  <a class="el" href="group__bridgeif.html#gac47f8ce66bc6dad5dd9829467f93a1bb">bridgeif_initdata_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Initialisation data for <a class="el" href="group__bridgeif.html#ga23cc2c5f8fccefc470093840cc53727c">bridgeif_init</a>. An instance of this type must be passed as parameter 'state' to <a class="el" href="group__netif.html#gade5498543e74067f28cc6bef0209e3be">netif_add</a> when the bridge is added. </p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga51b7d1af22f7023aabd8502aadf77c77"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga51b7d1af22f7023aabd8502aadf77c77">&#9670;&nbsp;</a></span>bridgeif_add_port()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> bridgeif_add_port </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structnetif.html">netif</a> *&#160;</td>
          <td class="paramname"><em>bridgeif</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct <a class="el" href="structnetif.html">netif</a> *&#160;</td>
          <td class="paramname"><em>portif</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Add a port to the bridge </p>

</div>
</div>
<a id="gad20fea2657431d4a0905be80cb0b4666"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad20fea2657431d4a0905be80cb0b4666">&#9670;&nbsp;</a></span>bridgeif_fdb_add()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> bridgeif_fdb_add </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structnetif.html">netif</a> *&#160;</td>
          <td class="paramname"><em>bridgeif</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const struct <a class="el" href="structeth__addr.html">eth_addr</a> *&#160;</td>
          <td class="paramname"><em>addr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bridgeif_portmask_t&#160;</td>
          <td class="paramname"><em>ports</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Add a static entry to the forwarding database. A static entry marks where frames to a specific eth address (unicast or group address) are forwarded. bits [0..(BRIDGEIF_MAX_PORTS-1)]: hw ports bit [BRIDGEIF_MAX_PORTS]: cpu port 0: drop </p>

</div>
</div>
<a id="ga79349b1e9d0f944e8abad5a6cfb1c8e8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga79349b1e9d0f944e8abad5a6cfb1c8e8">&#9670;&nbsp;</a></span>bridgeif_fdb_remove()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> bridgeif_fdb_remove </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structnetif.html">netif</a> *&#160;</td>
          <td class="paramname"><em>bridgeif</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const struct <a class="el" href="structeth__addr.html">eth_addr</a> *&#160;</td>
          <td class="paramname"><em>addr</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Remove a static entry from the forwarding database </p>

</div>
</div>
<a id="ga23cc2c5f8fccefc470093840cc53727c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga23cc2c5f8fccefc470093840cc53727c">&#9670;&nbsp;</a></span>bridgeif_init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> bridgeif_init </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structnetif.html">netif</a> *&#160;</td>
          <td class="paramname"><em>netif</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Initialization function passed to <a class="el" href="group__netif.html#gade5498543e74067f28cc6bef0209e3be">netif_add()</a>.</p>
<p>ATTENTION: A pointer to a <a class="el" href="group__bridgeif.html#gac47f8ce66bc6dad5dd9829467f93a1bb">bridgeif_initdata_t</a> must be passed as 'state' to <a class="el" href="group__netif.html#gade5498543e74067f28cc6bef0209e3be">netif_add</a> when adding the bridge. I supplies MAC address and controls memory allocation (number of ports, FDB size).</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">netif</td><td>the lwip network interface structure for this ethernetif </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>ERR_OK if the loopif is initialized ERR_MEM if private data couldn't be allocated any other err_t on error </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
